package com.pai4j.pgc.service.resource.convert;
import com.pai4j.common.util.IDGenerateUtil;
import com.pai4j.common.util.file.FileConvertUtil;
import com.pai4j.domain.community.vo.response.resource.ResourceConvertBufferImageResult;
import lombok.extern.slf4j.Slf4j;

/**
 * PDF转图片
 *
 * @author: CYM-pai
 * @date: 2025/10/31 12:23
 **/
@Slf4j
public class ExcelResourceConvertImageService extends AbstractResourceConvertImageService {

    @Override
    public ResourceConvertBufferImageResult doProcess() {
        try {
            String pdfPath = LOCAL_TEMP_DIR.concat(IDGenerateUtil.createId("TMP_PDF").concat(".pdf"));
            FileConvertUtil.doc2Pdf(file.getPath(), pdfPath);
            return new PDFResourceConvertImageService(pdfPath).doProcess();
        } catch (Exception e) {
            log.error("DOC转图片失败. file：{}", file.getPath(), e);
        }
        return null;
    }
}
